# -*- coding:utf-8 -*-

import eyed3
import os
import sys


def modifyID3(filedir,filename,title):
    filepath = os.path.join(filedir,filename)
    audiofile = eyed3.load(filepath)
    print audiofile.tag.artist
    audiofile.tag.artist = u"mmm"
    audiofile.tag.album = u"xx"
    audiofile.tag.title = title
    audiofile.tag.save()

prefix = r".mp3"

filedir=ur"F:\学习文档/其他/大家的日语/MP3/第一册/"

for eachfile in os.listdir(filedir):
    length = len(eachfile)
    filext= eachfile[length-4:length]

    if(cmp(prefix.upper(),filext.upper()))==0:
        filename = eachfile[0:length-4]
        print u""+filename
        modifyID3(filedir,eachfile,filename)